#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int i, j;
	int n, m,x=0;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)
	{
		j = i;
		if (i % 10 == m)
			x++;
		while (j / 10 != 0)
		{
			j = j / 10;
			if (j%10 == m)
				x++;
		}
	}
	printf("%d",x);

}